package com.illtamer.infinite.sillage.controller;

import com.illtamer.infinite.sillage.service.BlogService;
import com.illtamer.infinite.sillage.vo.MinBlog;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/archive")
public class ArchiveController {

    @Resource(name = "blogService")
    private BlogService blogService;

    @RequestMapping
    public String archive(Model model) {
        final Map<String, Map<String, List<MinBlog>>> yearWithMonthMap = blogService.listMinBlogOrderByYearWithMonth();
        model.addAttribute("yearWithMonthMap", yearWithMonthMap);
        return "archive";
    }

}
